package com.nkzy.service.impl;

import com.nkzy.mapper.UserMapper;
import com.nkzy.pojo.User;
import com.nkzy.service.UserService;
import com.nkzy.utils.Md5Util;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
//业务层完成项目相关的业务操作
@Service
public class UserServiceImpl implements UserService {
    //在UserService中要调用下层的方法，所以需要依赖注入
    @Resource
    private UserMapper userMapper;
    @Override
    public User findUserByName(String username) {
        User user = userMapper.selectUserByName(username);
        return user;
    }
    //注册，返回值为void
    @Override
    public void register(String username, String password) {
        //1.对密码进行加密
        String md5String = Md5Util.getMD5String(password);
        //2.注册
        userMapper.insert(username,md5String);
    }
    //注册，返回值为int
    @Override
    public int register01(String username, String password) {
        //1.对密码进行加密
        String md5String = Md5Util.getMD5String(password);
        //2.注册
        int i = userMapper.insert02(username, md5String);
        return i;
    }
}
